var t = getApp();

Page({
    data: {
        activeName: "0",
        activeReward: "0",
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        networkLoading: !1,
        member: {},
        incomeCount: 0,
        rewardCount: 0,
        myRewardCount: 0,
        unsettlement: 0,
        settlement: 0
    },
    onLoad: function(t) {
        this.getListData(), this.getCircleSet();
    },
    bindActiveNameChange: function(t) {
        console.log(t.detail), this.setData({
            activeName: t.detail.index,
            networkLoading: !1
        }), this.getListData();
    },
    bindActiveRewardChange: function(t) {
        this.setData({
            activeReward: t.detail.index,
            networkLoading: !1
        }), this.getListData();
    },
    getDetails: function() {
        var e = this, a = t.getNetAddresss("plugin.circle.frontend.circle.get-circle");
        t._postNetWork({
            url: a,
            data: {
                circle_id: this.data.circleId
            },
            success: function(a) {
                var i = a.data;
                if (1 != i.result) return t.tips(i.msg);
                e.setData({
                    circleInfo: i.data
                }), console.log(i);
            }
        });
    },
    initData: function() {
        this.setData({
            page: 1,
            total_page: 0,
            isLoadMore: !0,
            networkLoading: !1
        });
    },
    getListData: function() {
        var e = this;
        this.initData();
        var a = "", i = this.data, n = i.activeName, r = i.activeReward, s = {};
        0 == n ? a = t.getNetAddresss("plugin.circle.frontend.circle-pay.circle-pay-log-list") : 1 == n ? (a = t.getNetAddresss("plugin.circle.frontend.circle-pay.reward-log"), 
        s.reward_type = r, 0 == r && (s.reward_type = 2)) : 2 == n && (a = t.getNetAddresss("plugin.circle.frontend.circle-pay.get-video-reward")), 
        t._postNetWork({
            url: a,
            data: s,
            success: function(a) {
                var i = a.data;
                if (1 != i.result) return t.tips(i.msg);
                e.data.total_page = i.data.list.last_page, e.data.total_page || (e.data.total_page = 0), 
                0 == n && e.setData({
                    member: i.data.member,
                    incomeCount: i.data.incomeCount
                }), 1 == n && 0 == r && e.setData({
                    rewardCount: i.data.rewardCount,
                    myRewardCount: i.data.myRewardCount
                }), 2 == n && e.setData({
                    unsettlement: i.data.unsettlement,
                    settlement: i.data.settlement
                }), e.setData({
                    listData: i.data.list.data,
                    networkLoading: !0
                });
            }
        });
    },
    _getMoreData: function() {
        var e = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var a = t.getNetAddresss("plugin.circle.frontend.circle-member.get-circle-memberList"), i = {
                page: this.data.page
            }, n = this.data, r = n.activeName, s = n.activeReward;
            0 == r ? a = t.getNetAddresss("plugin.circle.frontend.circle-pay.circle-pay-log-list") : 1 == r ? (a = t.getNetAddresss("plugin.circle.frontend.circle-pay.reward-log"), 
            i.reward_type = s, 0 == s && (i.reward_type = 2)) : 2 == r && (a = t.getNetAddresss("plugin.circle.frontend.circle-pay.get-video-reward")), 
            t._postNetWork({
                url: a,
                data: i,
                success: function(t) {
                    var a = t.data;
                    if (e.data.isLoadMore = !0, 1 === a.result) {
                        var i = e.data.listData.concat(a.data.list.data);
                        e.setData({
                            listData: i
                        });
                    } else e.data.page = e.data.page - 1, e.data.isLoadMore = !1;
                }
            });
        }
    },
    getCircleSet: function() {
        var e = t.getNetAddresss("plugin.circle.frontend.circle.get-set");
        t._getNetWork({
            url: e,
            data: {},
            success: function(e) {
                var a = e.data;
                if (1 != a.result) return t.tips(a.msg);
                wx.setNavigationBarTitle({
                    title: a.data.plugin_name
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareTimeline: function() {},
    onShareAppMessage: function() {}
});